import pandas as pd

# 读取csv文件
df1 = pd.read_csv('专利.csv')
df2 = pd.read_csv('软著.csv')

# 提取统一社会信用代码列
set1 = set(df1['unifiedSocialCreditCode'])
set2 = set(df2['unifiedSocialCreditCode'])

# 只在df1有的
only_in_df1 = set1 - set2
# 只在df2有的
only_in_df2 = set2 - set1

# 筛选出对应的行
df1_only = df1[df1['unifiedSocialCreditCode'].isin(only_in_df1)]
df2_only = df2[df2['unifiedSocialCreditCode'].isin(only_in_df2)]

# 输出到新文件
df1_only.to_csv('only_in_file1.csv', index=False)
df2_only.to_csv('only_in_file2.csv', index=False)